package com.heima.controller;


import com.heima.annotation.OperationFill;
import com.heima.dto.pagedto.ReportPageDto;
import com.heima.service.ReportService;
import com.heima.vo.PageResult;
import com.heima.vo.ReportVo;
import com.heima.vo.ResultVo;
import com.heima.vo.reportvo.ActivityAndChannelNumNumVo;
import com.heima.vo.reportvo.REportVo;
import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;

@RestController
@RequiredArgsConstructor
@RequestMapping("/report")
@Slf4j
@Api(tags = "报表模块")
public class ReportController {

    private final ReportService reportService;

    /**
     * 客户统计
     * @param dto
     * @return
     */
    @GetMapping("/contractStatisticsList")
    @OperationFill
    public PageResult contractStatisticsList(ReportPageDto dto){
        log.info("客户统计");
        PageResult vo = reportService.contractStatisticsList(dto);
        return vo;
    }

    /**
     * 线索统计
     * @param dto
     * @return
     */
    @GetMapping("/cluesStatisticsList")
    @OperationFill
    public PageResult cluesStatisticsLisList(ReportPageDto dto){
        log.info("线索统计");
        PageResult vo = reportService.cluesStatisticsLisList(dto);
        return vo;
    }

    /**
     * 销售统计报表
     */
    @GetMapping("/deptStatisticsList/{begin}/{end}")
    public PageResult salesReport(Integer pageNum,Integer pageSize,
                                  @PathVariable String begin,@PathVariable String end){
        log.info("销售统计报表");
        PageResult result=reportService.getSalesReport(pageNum,pageSize,begin,end);
        return result;
    }

    /**
     * 客户统计可视化
     */
    @GetMapping("/contractStatistics/{beginTime}/{endTime}")
    public REportVo contractStatisticsListByTime(@PathVariable LocalDate beginTime,
                                                 @PathVariable LocalDate endTime){
        log.info("客户统计可视化:{},{}",beginTime,endTime);
        REportVo vo = reportService.contractStatisticsListByTime(beginTime,endTime);
        return vo;
    }

    /**
     * 销售可视化
     */
    @GetMapping("/salesStatistics/{beginTime}/{endTime}")
    public REportVo salesStatisticsByTime(@PathVariable LocalDate beginTime,
                                          @PathVariable LocalDate endTime){
        log.info("销售统计可视化:{},{}",beginTime,endTime);
        //,"tb_clue_count"
        REportVo vo = reportService.salesStatisticsByTime(beginTime,endTime);
        return vo;
    }

    /**
     * 线索统计可视化
     */
    @GetMapping("/cluesStatistics/{beginTime}/{endTime}")
    public REportVo cluesStatisticsListListByTime(@PathVariable LocalDate beginTime,
                                                  @PathVariable LocalDate endTime){
        log.info("线索统计可视化:{},{}",beginTime,endTime);
        //,"tb_clue_count"
        REportVo vo = reportService.cluesStatisticsListListByTime(beginTime,endTime);
        return vo;
    }



    /**
     * 活动饼图
     */
    @GetMapping("/chanelStatistics/{begin}/{end}")
    public ActivityAndChannelNumNumVo  ActivityNum(@PathVariable LocalDate begin,
                                                   @PathVariable LocalDate end){
        log.info("活动饼图{},{}",begin,end);
        ActivityAndChannelNumNumVo vo = reportService.activityNum(begin,end);
        return vo;
    }


    /**
     * 线索统计可视化
     */
//    @GetMapping("/cluesStatistics/{beginTime}/{endTime}")
//    public REportVo cluesStatisticsListListByTime2(@PathVariable LocalDate beginTime,
//                                                 @PathVariable LocalDate endTime){
//        log.info("客户统计可视化:{},{}",beginTime,endTime);
//        REportVo vo = reportService.contractStatisticsListByTime(beginTime,endTime);
//        return vo;
//    }

}
